<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script src="https://cdn.staticfile.net/jquery/3.7.1/jquery.min.js"></script>
  <title>Document</title>
</head>
<body>
<button id="get-btn">get</button>
<button id="post-btn">post</button>
<button id="delete-btn">delete</button>
</body>
<script>
    $(document).ready(() => {
        $("#get-btn").click(() => {
            $.ajax({
                url: "http://localhost:3000/api/books/getBooks?id=1",
                type: "GET",
                success: (res) => {
                    console.log(res);
                }
            })
        })
        $("#post-btn").click(() => {
            $.ajax({
                url: "http://localhost:3000/api/books/updateBook",
                type: "POST",
                data: JSON.stringify({
                    name: "新图书",
                    author: "新作者",
                    price: 99.00,
                    id: 1001
                }),
                contentType: "application/json",
                success: (res) => {
                    console.log(res);
                }
            })
        })
        $("#delete-btn").click(() => {
            $.ajax({
                url:"http://localhost:3000/api/books/deleteBook",
                type:"DELETE",
                success: (res) => {
                    console.log(res);
                }
            })
        })
    })
</script>
</html>
